<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link href="${ctxPath}/css/bootstrap.min.css" rel="stylesheet">
    <script src="${ctxPath}/js/jquery-3.2.1.min.js"></script>
    <script src="${ctxPath}/js/bootstrap.min.js"></script>

</head>
<body>

请输入用户名<input type="text" name="username" id="username"/><br/>
<button onclick="sub()">验证是否存在</button>

</body>
</html>

<script>
    function sub() {
        var username = $("#username").val();
        var url="${ctxPath}/check";
        $.ajax({
            type: "post",
            url: url,
            data: {"username": username},
            success:function (data) {
                console.log(data);
                if(data!=0){
                    alert("存在此用户");
                }
                else{
                    alert("不存在此用户");
                }
            },
            error:function (msg) {
                console.log(msg);
            }
        });
    }
</script>